package com.ddiviewer;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TextView;

public class DDIViewer extends TabActivity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		TabHost tabHost = getTabHost();
		//LayoutInflater.from(this).inflate(R.layout.tabindicator, tabHost.getTabContentView(), true);
		
		TabHost.TabSpec searchTab = tabHost.newTabSpec("searchTab");
		Intent in0 = new Intent(this, SearchTab.class);
		searchTab.setContent(in0);
		searchTab.setIndicator(new MyTabIndicator(this, "Search"));
		tabHost.addTab(searchTab);

		TabHost.TabSpec favoritesTab = tabHost.newTabSpec("favoritesTab");
		Intent in1 = new Intent(this, FavoritesTab.class);
		favoritesTab.setContent(in1);
		favoritesTab.setIndicator(new MyTabIndicator(this, "Favorites"));
		tabHost.addTab(favoritesTab);
		
		TabHost.TabSpec recentTab = tabHost.newTabSpec("recentTab");
		Intent in2 = new Intent(this, RecentTab.class);
		recentTab.setContent(in2);
		recentTab.setIndicator(new MyTabIndicator(this, "Recent"));
		tabHost.addTab(recentTab);
	}
	
    public static class MyTabIndicator extends LinearLayout {
		public MyTabIndicator(Context context, String label) {
			super(context);
			
			View tab = LayoutInflater.from(context).inflate(R.layout.tabindicator, this, true);

			TextView tv = (TextView) tab.findViewById(R.id.tablabel);
			tv.setText(label);
		}
    }

}